package com.yanqu.road.server.gameplayer.module.patrons;

import com.alibaba.fastjson.JSONObject;
import com.yanqu.data.analytics.helper.DataBuilder;
import com.yanqu.road.entity.config.skill.SkillInfo;
import com.yanqu.road.entity.log.LogVehicleBoneEquip;
import com.yanqu.road.entity.musicroom.UserMusicRoomBeautyData;
import com.yanqu.road.entity.player.CombLeaderSkill;
import com.yanqu.road.entity.player.UserCombLeaderData;
import com.yanqu.road.entity.player.UserVehicle;
import com.yanqu.road.entity.player.UserVehicleBone;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.vehicle.VehicleBoneModule;
import com.yanqu.road.server.gameplayer.module.vehicle.VehicleModule;
import com.yanqu.road.server.manger.DataAnalyticsMgr;
import com.yanqu.road.server.manger.config.GoodsMgr;
import com.yanqu.road.server.manger.config.SkillMgr;
import com.yanqu.road.server.manger.config.VehicleBoneConfigMgr;
import com.yanqu.road.server.manger.maidian.DefaultEventTraceAction;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class CombLeaderLog {
    /**
     * 每日首次登录传数数
     *
     * @param player
     */
    public static void traceLoginLog(GamePlayer player) {
        try {
            if (!DataAnalyticsMgr.openDataAnalytics()) return;
            CombLeaderModule module = player.getModule(CombLeaderModule.class);

            //技能id，技能上限等级，技能当前等级，是否上限{guest_tokskillid:数值,guest_tokskillmax:数值,guest_tokskillv:数值,guest_tokskillisfull:布尔值}
            for (UserCombLeaderData combLeaderData : module.getLeaderDataMap().values()) {
                List<JSONObject> skillList = new ArrayList<>();
                for (CombLeaderSkill combLeaderSkill : combLeaderData.getSkillMap().values()) {
                    SkillInfo skillInfo = SkillMgr.getSkillInfo(combLeaderSkill.getId());
                    if (skillInfo == null) {
                        continue;
                    }
                    int maxLevel = module.getMaxLevel(skillInfo);
                    JSONObject object = new JSONObject();
                    object.put("guest_tokskillid", combLeaderSkill.getId());
                    object.put("guest_tokskillv", combLeaderSkill.getLv() + combLeaderSkill.getSkinLv());
                    object.put("guest_tokskillmax", maxLevel);
                    object.put("guest_tokskillisfull", maxLevel == combLeaderSkill.getLv() + combLeaderSkill.getSkinLv());

                    skillList.add(object);
                }

                DefaultEventTraceAction action = new DefaultEventTraceAction("guest_choinfo", player);
                action.build("guest_id", combLeaderData.getLeaderId());
                action.build("guest_tokskill", skillList);
                action.trace();
            }
        } catch (Exception e) {
            DataAnalyticsMgr.getLogger().error(" error ", e);
        }
    }
}
